﻿@using lsc.Model
@{ 
    UserInfo user = ViewData["user"] as UserInfo;
    List<UserRoleJurisdiction> userrolejurlist = ViewData["userrolejurlist"] as List<UserRoleJurisdiction>;
    List<ModuleInfo> modulelist = ViewData["modulelist"] as List<ModuleInfo>;
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>@ViewData["Title"]</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="~/layui/css/layui.css">
    <link rel="stylesheet" href="~/layui/css/main.css">
    <script type="text/javascript" src="~/layui/layui.js"></script>
    <script type="text/javascript" src="~/layui/jquery.js"></script>

</head>
<body class="layui-layout-body" leftmargin=0 topmargin=0 oncontextmenu='return false' ondragstart='return false' onselectstart ='return false' onselect='document.selection.empty()' oncopy='document.selection.empty()' onbeforecopy='return false' onmouseup='document.selection.empty()'>
    <div class="layui-layout layui-layout-admin">
        <!-- 头部区域 -->
        <div class="layui-header">
            <div class="layui-logo">开源CRM</div>
            
            <ul class="layui-nav layui-layout-right">
                @if (user.TargetAmt <= 0)
                {
                    <li class="layui-nav-item">
                        <a href="javascript:;" onclick="setamtonclick()">设置月销售回款金额</a>
                    </li>
                }
                
                <li class="layui-nav-item">
                    <a href="javascript:;">@(user!=null ? user.Name:"")</a>
                    <dl class="layui-nav-child">
                        <dd><a href="javascript:;" onclick="basemsg()">基本资料</a></dd>
                    </dl>
                </li>
                <li class="layui-nav-item">
                    <a href="/Account/LoginOut">退出</a>
                </li>
            </ul>
        </div>
        <!-- 侧边栏 -->
        <div class="layui-side layui-bg-black">
            <div class="layui-side-scroll">
                <ul class="layui-nav layui-nav-tree" lay-filter="test">
                    <li class="layui-nav-item @(ViewBag.root=="console"?"layui-nav-itemed":"")"><a href="/EnterCustom/ConsoleIndex">工作台</a></li>
                    @if (modulelist != null && modulelist.Count > 0 && userrolejurlist != null && userrolejurlist.Count > 0)
                    {
                        var module1 = modulelist.FirstOrDefault(x => x.Name == "账户管理");
                        var modeule2 = modulelist.FirstOrDefault(x => x.Name == "模块管理");
                        var module3 = modulelist.FirstOrDefault(x => x.Name == "角色管理");
                        var module4 = modulelist.FirstOrDefault(x => x.Name == "用户管理");
                        var module5 = modulelist.FirstOrDefault(x => x.Name == "客户管理");
                        var module6 = modulelist.FirstOrDefault(x => x.Name == "客户信息管理");
                        var module7 = modulelist.FirstOrDefault(x => x.Name == "公共客户池");
                        var module8 = modulelist.FirstOrDefault(x => x.Name == "销售");
                        var module9 = modulelist.FirstOrDefault(x => x.Name == "项目管理");
                        var module10 = modulelist.FirstOrDefault(x => x.Name == "所有客户");
                        var module11 = modulelist.FirstOrDefault(x => x.Name == "统计分析");
                        var module12 = modulelist.FirstOrDefault(x => x.Name == "基本数据统计");
                        var module13 = modulelist.FirstOrDefault(x => x.Name == "题库");
                        var module14 = modulelist.FirstOrDefault(x => x.Name == "答题");
                        var module15 = modulelist.FirstOrDefault(x => x.Name == "员工答题记录");
                        var module16 = modulelist.FirstOrDefault(x => x.Name == "邮件营销管理");
                        if (module1 != null)
                        {
                            var userjur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module1.ID && x.IsQuery);

                            if (userjur != null)
                            {
                                <li class="layui-nav-item  @(ViewBag.root=="account"?"layui-nav-itemed":"")">
                                    <a class="" href="javascript:;">账户管理</a>
                                    <dl class="layui-nav-child">
                                        @if (modeule2 != null)
                                        {
                                            var modeule2_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == modeule2.ID && x.IsQuery);
                                            if (modeule2_jur != null)
                                            {
                                                <dd>
                                                    <a href="/Users/ModuleList">模块管理</a>
                                                </dd>
                                            }
                                        }
                                        @if (module3 != null)
                                        {
                                            var modeule3_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module3.ID && x.IsQuery);
                                            if (modeule3_jur != null)
                                            {
                                                <dd>
                                                    <a href="/Users/RoleList">角色管理</a>
                                                </dd>
                                            }
                                        }
                                        @if (module4 != null)
                                        {
                                            var modeule4_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module4.ID && x.IsQuery);
                                            if (modeule4_jur != null)
                                            {
                                                <dd>
                                                    <a href="/Users/UserList">用户管理</a>
                                                </dd>
                                            }
                                        }
                                        
                                    </dl>
                                </li>
                            }
                        }
                        if (module5 != null)
                        {
                            var modeule5_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module5.ID && x.IsQuery);
                            if (modeule5_jur != null)
                            {
                                <li class="layui-nav-item @(ViewBag.root=="enter"?"layui-nav-itemed":"")">
                                    <a href="javascript:;">客户管理</a>
                                    <dl class="layui-nav-child">
                                        @if (module6 != null)
                                        {
                                            var module6_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module6.ID && x.IsQuery);
                                            if (module6_jur != null)
                                            {
                                                <dd><a href="/EnterCustom/Index">客户信息管理</a></dd>
                                            }
                                        }
                                        @if (module7 != null)
                                        {
                                            var module7_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module7.ID && x.IsQuery);
                                            if (module7_jur != null)
                                            {
                                                <dd><a href="/EnterCustom/EnterPoolIndex">公共客户池</a></dd>
                                            }
                                        }
                                        @if (module10 != null)
                                        {
                                            var module10_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module10.ID && x.IsQuery);
                                            if (module10_jur != null)
                                            {
                                                <dd><a href="/EnterCustom/AllEnterList">所有客户</a></dd>
                                            }
                                        }
                                    </dl>
                                </li>
                            }

                        }
                        if (module8 != null)
                        {
                            var module8_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module8.ID && x.IsQuery);
                            if (module8_jur != null)
                            {
                                <li class="layui-nav-item @(ViewBag.root=="sale"?"layui-nav-itemed":"")">
                                    <a href="javascript:;">销售</a>
                                    <dl class="layui-nav-child">
                                        @if (module9 != null)
                                        {
                                            var module9_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module9.ID && x.IsQuery);
                                            if (module9_jur != null)
                                            {
                                                <dd><a href="/EnterCustom/SalesProjectIndex">项目管理</a></dd>
                                            }
                                        }
                                        @*<dd><a href="javascript:;">销售机会</a></dd>
                                        <dd><a href="javascript:;">竞争对手</a></dd>*@
                                    </dl>
                                </li>
                            }
                        }
                        <li class="layui-nav-item"><a href="/EnterCustom/WorkPlanIndex?pageIndex=1">工作计划</a></li>
                        if (module11 != null)
                        {
                            var module11_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module11.ID && x.IsQuery);
                            if (module11_jur != null)
                            {
                                <li class="layui-nav-item @(ViewBag.root=="report"?"layui-nav-itemed":"")">
                                    <a href="javascript:;">统计分析</a>
                                    <dl class="layui-nav-child">
                                        @if (module12!=null)
                                        {
                                            var module12_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module12.ID && x.IsQuery);
                                            if (module12_jur!=null)
                                            {
                                                <dd><a href="/Report/Index">基本数据统计</a></dd>
                                                <dd><a href="/Report/PhoneReport">每天电话量统计</a></dd>
                                            }
                                        }
                                    </dl>
                                </li>
                            }
                        }
                        if (module13 != null)
                        {
                            var module13_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module13.ID && x.IsQuery);
                            if (module13_jur != null)
                            {
                                <li class="layui-nav-item"><a href="/Ques/Index?pageIndex=1">题库</a></li>
                            }
                        }
                        if (module14!= null)
                        {
                            var module14_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module14.ID && x.IsQuery);
                            if (module14_jur != null)
                            {
                                <li class="layui-nav-item"><a href="/Ques/UserAnswerLogList?pageIndex=1">答题</a></li>
                            }
                        }

                        if (module15 != null)
                        {
                            var module15_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module15.ID && x.IsQuery);
                            if (module15_jur != null)
                            {
                                <li class="layui-nav-item"><a href="/Ques/UserAnswerLogs?pageIndex=1&userId=0">员工答题记录</a></li>
                            }
                        }
                        if (module16 != null)
                        {
                            var module16_jur = userrolejurlist.FirstOrDefault(x => x.ModuleID == module16.ID && x.IsQuery);
                            if (module16_jur != null)
                            {
                                <li class="layui-nav-item @(ViewBag.root=="email"?"layui-nav-itemed":"")">
                                    <a href="javascript:;">邮件营销</a>
                                    <dl class="layui-nav-child">
                                        <dd><a href="/EmailManage/Index">邮箱资源管理</a></dd>
                                        <dd><a asp-controller="EmailManage" asp-action="TargetEmailList">目标邮箱管理</a></dd>
                                        <dd><a asp-controller="EmailManage" asp-action="EmailTemplateList">邮件模板</a></dd>
                                        <dd><a asp-controller="EmailManage" asp-action="SendEmailTaskList">邮件发送任务</a></dd>
                                    </dl>
                                </li>
                            }
                        }
                    }
                </ul>
            </div>
        </div>

        <!-- 内容区域 -->
        <div class="layui-body">
            @RenderBody()
        </div>

        <!-- 底部固定区域 -->
        <div class="layui-footer">
            © 开源CRM - @DateTime.Now.Year
        </div>
    </div>
    <script>
        var layer
        layui.use('layer', function () {
            layer = layui.layer;
        }); 
        var setamtonclick = function () {
            layer.prompt({ title: '请输入您每月销售回款目标金额，并确认', formType: 3 }, function (text, index) {
                var re = /^[0-9]+.?[0-9]*$/;
                if (!re.test(text)) {
                    layer.alert('请输入数字', {
                        icon: 2,
                        skin: 'layer-ext-moon'
                    })
                    return;
                 }
                $.get('/EnterCustom/SetAmtTarget?amt=' + text, function (res) { 
                    layer.alert('设置成功!', {
                        icon: 1,
                        skin: 'layer-ext-moon'
                    })
                });
            });
        }
        var basemsg = function () { 
            layer.open({
                type: 2,
                title: '个人信息',
                shadeClose: true,
                shade: 0.8,
                area: ['200px', '20%'],
                content: '/Users/UserMessage'
            });
        }
    </script>
    @RenderSection("Scripts", required: false)
    
</body>
</html>